<?php
/**
 * 页头文件
 * 州弟医院信息系统 - 州弟学安全
 */
require_once 'includes/functions.php';
$current_page = basename($_SERVER['PHP_SELF']);
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo isset($pageTitle) ? $pageTitle . ' - ' . SITE_NAME : SITE_NAME; ?></title>
    <link rel="stylesheet" href="/assets\css/bootstrap_69c9e605.min.css">
    <link rel="stylesheet" href="/assets\css/all_3b858821.min.css">
    <link rel="stylesheet" href="/assets\css/style.css">
</head>
<body>
    <header>
        <nav class="navbar navbar-expand-lg navbar-dark bg-primary">
            <div class="container">
                <a class="navbar-brand" href="<?php echo SITE_URL; ?>">
                    <i class="fas fa-hospital-alt mr-2"></i><?php echo SITE_NAME; ?>
                </a>
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav">
                    <span class="navbar-toggler-icon"></span>
                </button>
                <div class="collapse navbar-collapse" id="navbarNav">
                    <ul class="navbar-nav mx-auto main-nav">
                        <li class="nav-item <?php echo ($current_page == 'index.php') ? 'active' : ''; ?>">
                            <a class="nav-link" href="<?php echo SITE_URL; ?>">首页</a>
                        </li>
                        <li class="nav-item <?php echo ($current_page == 'appointment.php') ? 'active' : ''; ?>">
                            <a class="nav-link" href="<?php echo SITE_URL; ?>appointment.php">预约挂号</a>
                        </li>
                        <li class="nav-item <?php echo ($current_page == 'departments.php') ? 'active' : ''; ?>">
                            <a class="nav-link" href="<?php echo SITE_URL; ?>departments.php">科室介绍</a>
                        </li>
                        <li class="nav-item <?php echo ($current_page == 'doctors.php') ? 'active' : ''; ?>">
                            <a class="nav-link" href="<?php echo SITE_URL; ?>doctors.php">医生团队</a>
                        </li>
                        <li class="nav-item <?php echo ($current_page == 'contact.php') ? 'active' : ''; ?>">
                            <a class="nav-link" href="<?php echo SITE_URL; ?>contact.php">联系我们</a>
                        </li>
                    </ul>
                    <ul class="navbar-nav auth-nav">
                        <?php if (isLoggedIn()): ?>
                            <li class="nav-item dropdown">
                                <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown">
                                    <i class="fas fa-user-circle mr-1"></i><?php echo $_SESSION['username']; ?>
                                </a>
                                <div class="dropdown-menu dropdown-menu-right">
                                    <?php if (hasRole('admin')): ?>
                                        <a class="dropdown-item" href="<?php echo SITE_URL; ?>admin/">
                                            <i class="fas fa-cogs mr-1"></i>管理后台
                                        </a>
                                        <div class="dropdown-divider"></div>
                                    <?php elseif (hasRole('doctor')): ?>
                                        <a class="dropdown-item" href="<?php echo SITE_URL; ?>doctor/">
                                            <i class="fas fa-stethoscope mr-1"></i>医生工作站
                                        </a>
                                        <div class="dropdown-divider"></div>
                                    <?php elseif (hasRole('patient')): ?>
                                        <a class="dropdown-item" href="<?php echo SITE_URL; ?>patient/">
                                            <i class="fas fa-procedures mr-1"></i>患者中心
                                        </a>
                                        <div class="dropdown-divider"></div>
                                    <?php endif; ?>
                                    <a class="dropdown-item" href="<?php echo SITE_URL; ?>profile.php">
                                        <i class="fas fa-id-card mr-1"></i>个人信息
                                    </a>
                                    <a class="dropdown-item" href="<?php echo SITE_URL; ?>logout.php">
                                        <i class="fas fa-sign-out-alt mr-1"></i>退出登录
                                    </a>
                                </div>
                            </li>
                        <?php else: ?>
                            <li class="nav-item <?php echo ($current_page == 'login.php') ? 'active' : ''; ?>">
                                <a class="nav-link auth-link" href="<?php echo SITE_URL; ?>login.php">
                                    <i class="fas fa-sign-in-alt mr-1"></i>登录
                                </a>
                            </li>
                            <li class="nav-item <?php echo ($current_page == 'register.php') ? 'active' : ''; ?>">
                                <a class="nav-link auth-link" href="<?php echo SITE_URL; ?>register.php">
                                    <i class="fas fa-user-plus mr-1"></i>注册
                                </a>
                            </li>
                        <?php endif; ?>
                    </ul>
                </div>
            </div>
        </nav>
    </header>
    
    <main>
        <?php
        // 显示消息提示
        if (isset($_SESSION['success_msg'])) {
            echo showSuccess($_SESSION['success_msg']);
            unset($_SESSION['success_msg']);
        }
        
        if (isset($_SESSION['error_msg'])) {
            echo showError($_SESSION['error_msg']);
            unset($_SESSION['error_msg']);
        }
        ?>
    </main>
</body>
</html> 